package com.example.chatchatbackend.Controller;

import com.example.chatchatbackend.entity.RestBean;

import com.example.chatchatbackend.entity.vo.response.RobootVO;
import com.example.chatchatbackend.service.RobootService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author 丁真
 * @since 2024-10-28 05:03:47
 */
@Slf4j
@RestController
@RequestMapping("/api/roboot")
public class RobootController {


    @Autowired
    private RobootService robootService;

    @GetMapping
    public RestBean<List<RobootVO>> getAllComment(){
        return RestBean.success(robootService.getAllRoboot());
    }

    @PostMapping
    public RestBean<RobootVO> insertRoboot(@RequestBody RobootVO robootVO){
        RobootVO insertRobootVO = robootService.insertRoboot(robootVO);
        return RestBean.success(insertRobootVO);

    }

    @PostMapping("/list")
    public RestBean<List<RobootVO>> insertRobootList (@RequestBody List<RobootVO> robootVO){
        List<RobootVO> RobootList = robootService.insertRobootList(robootVO);
        return RestBean.success(RobootList);
    }


    @PutMapping
    public RestBean<RobootVO> updateRoboot(@RequestBody RobootVO robootVO){
        return RestBean.success(robootService.updateRoboot(robootVO));

    }


    @GetMapping("/title")
    public RestBean<List<RobootVO>> findByTitle(@RequestBody String name ){
        List<RobootVO> robootList = robootService.findByTitle(name);
        return RestBean.success(robootList);
    }

}
